package com.gipson.amc.service.basicdata;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gipson.amc.entity.RoleAuthority;
import com.gipson.amc.mapper.RoleAuthorityMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色权限 服务实现类
 * </p>
 *
 * @author xsyuan
 * @since 2020-03-27
 */
@Service
public class RoleAuthorityService extends ServiceImpl<RoleAuthorityMapper, RoleAuthority> {

    public List<RoleAuthority> getListByRoleId(String roleId){
        List<RoleAuthority> roleAuthorityList = list(Wrappers.<RoleAuthority>lambdaQuery()
                .eq(RoleAuthority::getRoleId, roleId)
        );
        return roleAuthorityList;
    }

    public void deleteByRoleId(String roleCode){
         baseMapper.deleteByRoleId(roleCode);
    }

    public void deleteByRoleIds(String roleIds){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("roleIds", StringUtils.split(roleIds, ","));
        baseMapper.deleteByRoleIds(map);
    }


}
